//package top.qitun.config;
//
//import java.util.List;
//import java.util.stream.Collectors;
//
//import org.springframework.security.authentication.AnonymousAuthenticationToken;
//import org.springframework.security.authentication.AuthenticationProvider;
//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
//import org.springframework.stereotype.Component;
//
//
//@Component
//public class JsonWebTokenAuthenticationProvider implements AuthenticationProvider {
//
//	@Override
//	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
//		Authentication authenticatedUser = null;
//		// Only process the PreAuthenticatedAuthenticationToken
//		if (authentication.getClass().isAssignableFrom(UsernamePasswordAuthenticationToken.class)
//				&& authentication.getPrincipal() != null) {
//			String tokenHeader = (String) authentication.getPrincipal();
//			authenticatedUser = new AnonymousAuthenticationToken("1", tokenHeader, authentication.getAuthorities());
//		} else {
//			// It is already a JsonWebTokenAuthentication
//			authenticatedUser = authentication;
//		}
//		return authenticatedUser;
//	}
//
//	@Override
//	public boolean supports(Class<?> authentication) {
//		return authentication.isAssignableFrom(UsernamePasswordAuthenticationToken.class);
//	}
//	
//}
